<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>工作人员管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
        var validateForm;
        function doSubmit(){//回调函数，在编辑和保存动作时，供openDialog调用提交表单。
            if(validateForm.form()){
                $("#inputForm").submit();
                return true;
            }

            return false;
        }
        $(document).ready(function() {
            jQuery.validator.addMethod("isPhone", function(value, element) {
                var length = value.length;
                var mobile = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1})|(17[0-9]{1}))+\d{8})$/;
                return this.optional(element) || (length == 11 && mobile.test(value));
            }, "请填写正确的手机号码");//可以自定义默认提示信息

            validateForm = $("#inputForm").validate({
                rules: {
                    mobile : {
                        isPhone:true
                    }
                },
                messages: {
                    mobile : {
                        isPhone:"请填写正确的手机号码"
                    }
                },
                submitHandler: function(form){
                    loading('正在提交，请稍等...');
                    form.submit();
                },
                errorContainer: "#messageBox",
                errorPlacement: function(error, element) {
                    $("#messageBox").text("输入有误，请先更正。");
                    if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
                        error.appendTo(element.parent().parent());
                    } else {
                        error.insertAfter(element);
                    }
                }
            });

        });
	</script>
</head>
<body class="hideScroll">
	<form:form id="inputForm" modelAttribute="worker" action="${ctx}/woms/worker/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<sys:message content="${message}"/>	
		<table class="table table-bordered  table-condensed dataTables-example dataTable no-footer">
		   <tbody>
			   <tr>
				   <td class="width-15 active"><label class="pull-right">姓名：</label></td>
				   <td class="width-35">
					   <form:input path="name" htmlEscape="false"    class="form-control required"/>
				   </td>
			   </tr>
			   <tr>
				   <td class="width-15 active"><label class="pull-right">手机号：</label></td>
				   <td class="width-35">
					   <form:input path="mobile" htmlEscape="false"    class="form-control required"/>
				   </td>
			   </tr>
			   <tr>
				   <td class="width-15 active"><label class="pull-right">性别：</label></td>
				   <td class="width-35">
				   <form:select path="sex" class="form-control required">
					   <form:option value="" label=""/>
					   <form:options items="${fns:getDictList('sex')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
				   </form:select>
			   </tr>
			   <tr>
				   <td class="width-15 active"><label class="pull-right">角色名称：</label></td>
				   <td class="width-35">
				   <form:select path="roles" class="form-control required">
					   <form:option value="" label=""/>
					   <form:options items="${fns:getDictList('worker_role')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
				   </form:select>
			   </tr>
			   <tr>
				   <td class="width-15 active"><label class="pull-right">关联项目：</label></td>
				   <td class="width-35">
					   <form:checkboxes path="projectsList" items="${fns:getDictList('operation_area')}" itemLabel="label" itemValue="value" htmlEscape="false" class="input-sm required i-checks"/>
				   </td>
			   </tr>
			   <tr>
				   <td class="width-15 active"><label class="pull-right">备注信息：</label></td>
				   <td class="width-35">
					   <form:textarea path="remarks" htmlEscape="false" rows="4"    class="form-control "/>
				   </td>
			   </tr>
		   </tbody>
		</table>
		</div>
	</form:form>
</body>
</html>